I agree with all this but how is God going to distinguish between those who have taken or not taken the mark in Revelation ?
While talking about what this mark is probably leads into a tangent; but at its core this mark is intended as a kind of antithesis to God's seal. In the Revelation people are described as either having the mark of the beast, or having God's seal; both are described as being on the forehead (the mark is also described as on the right hand). This echoes biblical language we find elsewhere in Scripture, when Moses came down from the mountain and gave God's instructions--Torah--to them, they were instructed to have these precepts marked upon their foreheads and right hands. This is why, at least by Jesus' time, and it's still Rabbinic Jewish practice today, many observant Jews wear teffilin, or "phylacteries", these are small boxes that contain the Shema (Deuteronomy 6:4) which are worn with a strap around the forehead and right hand. While the meaning of the commandment wasn't meant to be literal--literally wearing this commandment--but rather being sealed with it in the sense of this is what identifies God's Covenant people, having His Law upon them (teffilin are physical representations of this). In other words, God's people were to be sealed, marked, identified as His by having His word, His commandments. In the New Testament St. Paul also speaks of God's People as having a seal, saying that we are sealed by the Holy Spirit through the Gospel which we believe.
So there is a recurring theme of being marked or sealed by God, that we belong to Him. When St. John talks about there being a mark of the beast, this is also the same kind of thing, but rather than it being about belonging to God, it is about belonging to the beast. It places allegiance to the beast as antithetical to allegiance to God. This is explicit in the Revelation, where there is a clear choice: one can either belong to Christ or one can belong to the beast.
To specifically answer this question: God knows who are His because He's God. In that sense, it's really that simple.
Anything beyond that is just commentary. There are lots of ways Scripture talks about how we belong to God. In Ephesians we read that God chose us in Christ to be heirs of the promise--God has always known us, always loved us. He knew us and loved us before the creation of the universe. And He chose us, in Christ, to be the objects of His love. This subject alone can, and literally does, fill libraries of books on theology and biblical exegesis. When Scripture talks about Baptism, it talks about how we have been united to Christ--to His life, death, and resurrection. Scripture talks about how we are, by God's grace, in Christ, there is a a mystical union between the believer and Jesus, that union is what makes us members of His Mystical Body--His Church. Scripture speaks of Baptism, and the Lord's Supper as sacred things, visible expressions of this truth: We are baptized into Christ, we "put on Christ" (Galatians 3:27, to give just one of many examples), when we come and gather at the Lord's Table we partake of Christ's body, we partake of Christ's blood. In the same way that wheat is gathered and brought together and baked into one loaf of bread, so we, gathered together are brought into the one load of bread, the one Body, of Christ. This is a constant refrain throughout Scripture, we belong to Jesus, we are in Jesus, we have received an identity that is in and with Jesus Christ, that makes us His, and this comes from God's own love, by His grace, and it is something God decrees and reveals and shows us through the visible expression of His grace--through the Church, proclaimed in His word--in Scripture--and in the Sacraments.
So that there really is no question that God knows us; what Scripture is trying to teach us is that
we can know this too. By faith. By looking outside of ourselves to what Jesus has done, and where God's grace makes contact with us--through things like hearing the Gospel preached, by what is written in Scripture, by looking to the water of Baptism, by looking at the bread and wine of Holy Communion. All of these things are ways which God is telling us we are His--of course He knows this (He's God), but He wants to build up our faith, strengthen our faith, ground us in the promise of the Gospel, by having us know Him through Jesus. Though right now we "see through a glass dimly" because we are finite, our knowledge is incomplete, we only know glimpses of glory; but there will be a Day when what is beheld by faith is beheld by sight. Theologians call this "the Beatific Vision" literally "the Blessed Vision". And, again, there are literally libraries full of books on this massive subject. Indeed, each small part of what I've been talking about is on its own the stuff of major and beautiful theological tomes.
So if you want a broader answer: God knows that we are His, because we are in Christ. How can we know that we are in Christ? Well, look to the Gospel, look to God's promises, look to your baptism, look to the Lord's Supper. Here is where God is telling you, "You belong to Me". And therefore we can have confidence of this.
And if you belong to Christ, then you don't belong to the beast. You can't belong to the beast if you belong to Christ. If you are already Christ's servant, then you belong to no other master. For Christ is your Master.
-CryptoLutheran